package cn.iocoder.yudao.module.self.mq.configuration;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicRabbitConfig {
    private String exchangeName = "topicExchange";
    private String queueName_man = "topic.man";
    private String queueName_woman = "topic.woman";
    private String queueName_woman_other = "topic.woman.other";

    @Bean
    public Queue firstQueue(){
        return new Queue(queueName_man,true);
    }

    @Bean
    public Queue secondQueue(){
        return new Queue(queueName_woman,true);
    }

    @Bean
    public Queue thirdQueue(){
        return new Queue(queueName_woman_other,true);
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(exchangeName,true,false);
    }

    @Bean
    Binding bindingTopicMessage(){
        Binding firstBinding = BindingBuilder.bind(firstQueue()).to(topicExchange()).with(queueName_man);
        return firstBinding;
    }

    @Bean
    Binding bindingTopicMessage2(){
        Binding firstBinding = BindingBuilder.bind(secondQueue()).to(topicExchange()).with("topic.#");
        return firstBinding;
    }

    @Bean
    Binding bindingTopicMessage3(){
        Binding firstBinding = BindingBuilder.bind(thirdQueue()).to(topicExchange()).with("topic.*");
        return firstBinding;
    }
}
